-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make query for GL_MAX_VIEWPORT_DIMS
compatible with web exports
#92851
Make query for GL_MAX_VIEWPORT_DIMS
compatible with web exports
#92851
Conversation
I can't take a look now. But we should double check the specification for OpenGL 3.3 and OpenGL ES 3.0 and see if the return value for |
From https://registry.khronos.org/OpenGL/specs/es/3.0/es_spec_3.0.pdf
I think we're safe with 32 bit GetIntegerv. |
GL_MAX_VIEWPORT_DIMS
compatible with web exports
1b2115b
to
20d5b6c
Compare
So I more or less reverted most of the changes from #80909 From the documentation, it seems that actually MAX_UNIFORM_BLOCK_SIZE should be queried as 64 bit. The remaining variables remain GLint (32-bit).
buffer sizeBy the way, I checked where the references to godot/drivers/gles3/storage/material_storage.cpp Lines 1111 to 1115 in 5833f59
viewport dimsI changed the reading of CC: @RandomShaper #90913
shader_gles3For consistency and DRY, is it safe to add a reference to the singleton from Config in godot/drivers/gles3/shader_gles3.cpp Line 804 in 5833f59
|
We should probably clamp
That's right. Reading from the Window is what caused the issue, reading from Config/Utilities is fine.
Its not a problem. This just sets the Viewport size. The actual drawing will be limited to the size of the framebuffer/texture.
Yes. |
20d5b6c
to
ed5f33e
Compare
OK, how does it look now? I've added CLAMP in
💣 One more thing, as I am assuming, |
Yes, Config is initialized before any shaders. I don't think any of the shaders are initialized from threads by the way. I'm fairly certain all shader initialization happens on the rendering thread and at initialization time. |
Ah, yes, my mistake. godot/drivers/gles3/rasterizer_gles3.cpp Lines 348 to 363 in ac95e0f
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Thanks! |
Info
This is an attempt to fix #92601 which turned out to be more puzzling than I originally thought.
Investigation
As described in the original bug, tooltips in web exports were not moving correctly to avoid being cut off by the edge of the screen. At the same time, Windows and Linux exports were working correctly.
The problem was that in
godot/scene/main/viewport.cpp
the functionpanel->get_max_size()
was returning values of 0/0 making the functionmin()
to set the tooltip size to zero. In fact, it happened only in web exports.godot/scene/main/viewport.cpp
Line 1505 in e96ad5a
Going a step further,
get_max_size()
returned the value of themax_viewport_size
variable from the Config class ofdrivers/gles3/storage/config.cpp
. This value should be set by querying the GL driver for theGL_MAX_VIEWPORT_DIMS
variable.godot/drivers/gles3/storage/config.h
Line 63 in e96ad5a
godot/drivers/gles3/storage/config.cpp
Lines 83 to 87 in e96ad5a
Here is the source of the problem, because it turns out that in the case of web export, query for GL_MAX_VIEWPORT_DIMS does not save anything. Of these above 5 queries, the first 4 work correctly and the last 4 do not. The variable is not changed at all, if we write some values to it beforehand it remains the same.
However, it turns out that in the
drivers/gles3/rasterizer_gles3.cpp
file, a differentglGetIntegerv
function is used for the same query. It works in both Windows / Linux and web exports.godot/drivers/gles3/rasterizer_gles3.cpp
Lines 401 to 402 in e96ad5a
Fix
My suggested fix is to replace
glGetInteger64v
withglGetIntegerv
. Unfortunatelymax_viewport_size
in Config class is of typeint64_t [2]
andglGetIntegerv
operates onGLint * data
(32 bit).Please review if it is possible to somehow rewrite the values of these variables more elegantly?
https://www.khronos.org/opengl/wiki/OpenGL_Type
Notes
The
glGetInteger64v
function is used in Godot only in thedrivers/gles3/storage/config.cpp
anddrivers/gles3/shader_gles3.cpp
files. It seems that except for one case it doesn't cause any other problems, but the mystery for me remains why it doesn't work forGL_MAX_VIEWPORT_DIMS
(this is the only case where it sets an array and not a single variable).Perhaps the problem is that the web export is in WASM32? I have not tested 32-bit Windows / Linux exports.
In addition, according to the Khronos table,
glGetInteger64v
officialy appeared in OpenGL 3.2 / OpenGL ES 3.0 andglGetIntegerv
had been around since OpenGL 2.0 / OpenGL ES 2.0.https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGet.xhtml
https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glGet.xhtml